osName <- Sys.info()['sysname'] 

if (osName == 'Windows'){
  prefix <- 'N:'  
  libLoc <- 'N:/SIL-Common/RPackages'
} else{
  prefix <- '/NDrive'  
  libLoc <- NULL
}

##File paths
rawDatDir2 <- paste0(prefix,"/HospitalChoice-P146101-BE/Work/FloridaAnalysis/Data/")
rawDatDir <- paste0(prefix,"/State Hospital Data Repository/State Hospital Data-BE/Florida/Raw Data/")
cbsaDatPath <- paste0(prefix,"/SIL-Common/Hospital Files/Geography/zip_msa_xwalk2010.dta")
AHAFile <- paste0(prefix,"/SIL-Common/Hospital Files/AHA Data/Current/11_15_2016AHA.csv")
travelFile <- paste0(prefix,"/HospitalChoice-P146101-BE/Work/SwitchCostSandbox/Data/RawData/allFL_8amWed.dta")
censusDatDir <- paste0(prefix,"/HospitalChoice-P146101-BE/Work/SwitchCostSandbox/Data/RawData/")
datDir <- paste0(prefix,"/HospitalChoice-P146101-BE/Work/SwitchCostSandbox/Data/")
resultsDir <- paste0(prefix,"/HospitalChoice-P146101-BE/Work/SwitchCostSandbox/Results/")
programDir <- paste0(prefix,"/HospitalChoice-P146101-BE/Work/SwitchCostSandbox/Programs/")
paramFilePref <- paste0(prefix,"/HospitalChoice-P146101-BE/Work/SwitchCostSandbox/Param/")

setwd(programDir)

timeMkt <- 45 ##Max time used to define market for choice sets
minZipHospPpl <- 5 ##If fewer than this number of people in a zipcode go to a hospital the hospital is included in the outside option
ageCut06 <- 21 ##Age in 2006 cutoff for inclusion
xiSmallGrp <- 100 ##Size of minimum number of people in zip code to include in xis
smallZipSize <- 500 ##Exclude zip codes without this number of total births over the sample period 

##Graph parameters
widthPaper =  14.11
heightPaper = 14.11
unitsPaper = 'cm'

widthPres = (12/8) * 14.11
heightPres = 14.11
unitsPres = 'cm'

dpiPlot <- 300

cbbPalette <- c("#000000",  "#56B4E9", "#009E73", "#F0E442", "#0072B2", "#D55E00", "#CC79A7")



##Preprocessing commands
library(data.table,lib.loc = libLoc)
library(ggplot2, lib.loc = libLoc)
library(plyr, lib.loc = libLoc)
library(foreign)
library(maxLik, lib.loc = libLoc)
library(proto, lib.loc = libLoc)
library(zoo, lib.loc = libLoc)
library(scales, lib.loc = libLoc)
library(grid, lib.loc = libLoc)
library(reshape2, lib.loc = libLoc)
library(e1071, lib.loc = libLoc)
library(MASS, lib.loc = libLoc)
library(miscTools, lib.loc = libLoc)
library(maxLik, lib.loc = libLoc)
library(parallel, lib.loc = libLoc)
library(miscTools,lib.loc=libLoc)
library(Formula,lib.loc=libLoc)
library(xtable,lib.loc=libLoc)
library(doParallel,lib.loc=libLoc)
library(stringr,lib.loc=libLoc)
library(stargazer,lib.loc=libLoc)
library(lfe,lib.loc = libLoc)
library(sandwich,lib.loc = libLoc)
library(car,lib.loc=libLoc)
options(datatable.auto.index=FALSE)

##Write some parameters to files to be read by stata
for (var in c('minZipHospPpl','ageCut06')){
    fileConn <- file(paste0(paramFilePref, var, ".txt"))
    writeLines(as.character(get(var)), fileConn)
    close(fileConn)
}
 
